package com.ymx.darling.dialect.page;
import java.util.List;

/**
 * 保存分页数据
 * @author 爱Java的小于
 */
public class PageMpl<T> implements Page<T> {
    private List<T> valueList;
    private Integer count;
    private Integer pageNum;
    private Integer pageSize;

    public void setCount(Integer count) {
        this.count = count;
    }

    public void setPageNum(Integer pageNum) {
        this.pageNum = pageNum;
    }

    public void setPageSize(Integer pageSize) {
        this.pageSize = pageSize;
    }

    public void setValueList(List<T> valueList) {
        this.valueList = valueList;
    }

    @Override
    public Integer getCurrent() {
        return this.pageNum;
    }

    @Override
    public Integer getSize() {
        return this.valueList.size();
    }

    @Override
    public List<T> getList() {
        return this.valueList;
    }

    @Override
    public Integer getTotal() {
        return this.count;
    }

    @Override
    public Integer getPageCount() {
        return count % this.pageSize == 0
                ? count / this.pageSize
                : (count / this.pageSize) + 1;
    }
}
